<?php
class Listmail_model extends CI_Model
{
    public $table = 'mail_schedule';

    function getAllByStatus($status = 1)
    {
        return $this->db
            ->where('status', $status)
            ->order_by("id", "desc")
            ->limit(1)
            ->get($this->table)
            ->row_array();
    }

    function ative()
    {
        $data = $this->getAllByStatus(1);
        $host = trim($data['hosts']);
        $arr1 = explode(';', $host);

        foreach($arr1 as $arr) {
            $arr2[] = str_replace('@', ':', trim($arr));
        }

        foreach ($arr2 as $arr) {
            $hosts[] = explode(':', trim($arr));
        }
        foreach ($hosts as $itemt) {
            list($user, $pass, $host, $post) = $itemt;
            $test[] = array('user'=>$user, 'pass'=>$pass, 'host'=>$host, 'post'=>$post,);
        }

        $mail = trim($data['mail_lists']);
        $listmail = explode(',', $mail);
        $data['mail_lists'] = $listmail;
        $data['hosts'] = $test;
        $data['status'] = 2;

        return $data;
    }
}
?>